/****************************************************************
 * <strong>MFJstlView</strong>
 *
 * <p>
 * MFJstlView
 * </p>
 *
 * @author AndyZhang 2013
 * @version 0.1
 * ToDo:2013-3-3
 ***************************************************************/
package com.thinkwide.data.mvc.view;

import com.thinkwide.data.mvc.core.IMFView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

public class MFJstlView implements IMFView {
    private String url;

    public MFJstlView(String url) {
        this.url = url;
    }

    public String getContentType() {

        return null;
    }

    public void render(Map<String, Object> map, HttpServletRequest request,
                       HttpServletResponse response) throws Exception {

        if (map != null)
            for (Map.Entry<String, Object> item : map.entrySet()) {
                request.setAttribute(item.getKey(), item.getValue());
            }

        if (!url.endsWith(".jsp")) url = url + ".jsp";
        request.getRequestDispatcher(url).forward(request, response);

    }

}
